package com.qf.pojo;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.config.BeanPostProcessor;

/**
 * @version 1.0
 * @auther Administrator
 * @date 2023/2/7 9:52
 * 测试对象的生命周期
 */

public class LifeCycleDemo implements BeanNameAware, BeanFactoryAware, InitializingBean, BeanPostProcessor {

    private User user;
    public void setUser(User user) {
        System.out.println("LifeCycleDemo:依赖注入");
        this.user = user;
    }

    public LifeCycleDemo(){
        System.out.println("LifeCycleDemo:构造器");
    }
    //初始化
    public void init(){
        System.out.println("LifeCycleDemo:初始化");
    }
    //销毁
    public void destroy(){
        System.out.println("LifeCycleDemo:销毁");
    }

    @Override
    public void setBeanName(String s) {
        System.out.println("LifeCycleDemo:setBeanName");
    }

    @Override
    public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
        System.out.println("LifeCycleDemo:setBeanFactory");
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        System.out.println("LifeCycleDemo:afterPropertiesSet");

    }
}
